import { sum } from 'lodash-es';

/**
 * 代码库背景颜色
 * @param {string} name 代码库名
 * @returns {string} 16进制颜色
 */
const AvatarColorList = ['#EDC078', '#C8DC78', '#81D0CF', '#90CDF5', '#A2A6EA'];

export function cumputeAvatarColor(name = '') {
  if (!name) {
    return '#ddd';
  }

  const result = sum(name.toUpperCase().split('').map((e) => e.charCodeAt(0)));

  return AvatarColorList[result % AvatarColorList.length];
}
